package com.tanhua.autoconfig;

import com.tanhua.autoconfig.properties.*;
import com.tanhua.autoconfig.template.*;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * 在自动装配类上，通过注解引入SmsProperties
 */
//相当于在SmsProperties类上，加入@Configuration
@EnableConfigurationProperties(
        value = {
                SmsProperties.class,  //查找配置文件，封装对象，存入容器
                OssProperties.class,
                AipFaceProperties.class,
                HuanXinProperties.class,
                GreenProperties.class
        }
)
public class TanhuaAutoConfiguration {


    /**
     * 方法：需要配置@Bean
     *   返回值：自动创建对象，将对象存入容器中
     */
    @Bean
    public SmsTemplate smsTemplate() {
        return new SmsTemplate();
    }


    @Bean
    public OssTemplate ossTemplate() {
        return new OssTemplate();
    }

    @Bean
    public AipFaceTemplate aipFaceTemplate() {
        return new AipFaceTemplate();
    }

    @Bean
    public HuanXinTemplate huanXinTemplate(HuanXinProperties properties) {
        return new HuanXinTemplate(properties);
    }

    @Bean
    public AliyunGreenTemplate aliyunGreenTemplate(GreenProperties properties) {
        return new AliyunGreenTemplate(properties);
    }
}
